package com.iot08.api.filter;

import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author weichao 1299101858@qq.com
 * @version 1.0
 * @date 2/26/22 10:38 AM
 */

@Component

@WebFilter(filterName="handleFilter",urlPatterns="/*")

public class HandleFilter extends OncePerRequestFilter {

    @Override

    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

        //TODO 此处匹配请求路径是否实行自定义拦截
        if(request.getServletPath().contains("/aliCSBack/") // 阿里云内容审核回调
                ){
            filterChain.doFilter(request, response);
            return;
        }
        ModifyParametersWrapper mParametersWrapper = new ModifyParametersWrapper(request);

        filterChain.doFilter(mParametersWrapper, response);

    }

}

